package com.example.spzx.Mapper;

import com.example.spzx.model.dto.product.ProductDto;
import com.example.spzx.model.entity.base.ProductUnit;
import com.example.spzx.model.entity.product.Product;
import com.example.spzx.model.entity.product.ProductDetails;
import com.example.spzx.model.entity.product.ProductSku;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Select("select * from product_unit")
    List<ProductUnit> getlist();

    Page<Product> getpage(ProductDto productDto);

    void save(Product product);

    void savesku(ProductSku productSku);
@Select("select * from product where id=#{id}")
    Product getbyid(Integer id);
@Select("select * from product_sku where product_id=#{id} ")
    List<ProductSku> getskubyid(Integer id);
@Delete("delete from product_sku where product_id=#{id} ")
    void deleteskuByid(Long id);

    void updateByid(Product product);

    void saveProductDetail(ProductDetails productDetails);

    void updatedetail(ProductDetails productDetails);
@Select("select * from product_details where product_id=#{id}")
    ProductDetails selectbyid(Long id);
    @Select("select * from product_unit where id=#{id}")
    String getunit(Long id);
@Delete("delete from product where id=#{id}")
    void deleteById(Integer id);
    @Delete("delete from product_detail where product_id=#{id}")
    void deleteBydetail(Integer id);
    @Delete("delete from product_attr where product_id=#{id}")
    void deleteByattr(Integer id);
}
